package com.yu.xcx.controller;


import com.yu.xcx.dto.Result;
import com.yu.xcx.entity.ShopFollow;
import com.yu.xcx.service.IShopFollowService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/shopFollow")
public class ShopFollowController {

    @Resource
    private IShopFollowService shopFollowService;

    //收藏或取消收藏商品
    @PostMapping("/followOrNot")
    public Result saveShopFollow(ShopFollow shopFollow, boolean flag){
        return shopFollowService.follow(shopFollow, flag);
    }

    //根据用户id得到收藏的全部商品
    @GetMapping("getShop")
    public Result getFollowShops(@RequestParam("userId") Integer userId, @RequestParam(value = "pagenum",defaultValue = "1") Integer pagenum){
        return shopFollowService.queryFollowShop(userId, pagenum);
    }

    //判断用户是否收藏商品
    @GetMapping("isFollow")
    public Result isFollow(ShopFollow shopFollow){
        return Result.ok(shopFollowService.isFollow(shopFollow));
    }

}
